package com.um.jdy.platform.month.controller;

import com.um.jdy.common.month.entity.dto.CardUserDTO;
import com.um.jdy.common.month.entity.po.CardUser;
import com.um.jdy.platform.month.entity.dto.CardUserPageDTO;
import com.um.jdy.platform.month.entity.vo.CardOrderItemVO;
import com.um.jdy.platform.month.entity.vo.CardUserItemVO;
import com.um.jdy.platform.month.manager.CardUserManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.manager.BasePlusManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器：月卡用户表
 */
@RestController
@RequestMapping("/api/v1/cms/month/card_user")
@Api(tags = "月卡用户表", description = "CardUserController")
@ApiPermission("card_user")
@Validated
@TokenRequired
public class CardUserController extends BaseController<CardUserManager> {

    /**
     * 分页查询月卡用户
     *
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("分页查询月卡用户")
    @PostMapping("page")
    public Response<Page<CardUserItemVO>> getPage(@RequestBody CardUserPageDTO params) {
        return manager.getPage(params.toPageParams());
    }

    @ApiPermission("update")
    @ApiOperation("更新")
    @PutMapping({"{id}"})
    public Response<CardUser> update(@PathVariable String id, @RequestBody CardUserDTO dto) {
        return this.manager.updateEntity(id, dto);
    }
}
